View hierarchy

A view hierarchy defines the relationships of views in a window to each other. You can think of a view hierarchy as an inverted tree structure with the window being the top node of the tree. Under it come views structurally specified by parent-child relationships. From a visual perspective, the essential fact of a view hierarchy is enclosure: one view contains one or more other views, and the window contains them all.

The view hierarchy is a major part of the responder chain, and it is something that the application frameworks use to determine the layering order of views when they render the content of a window in a drawing pass. The view hierarchy is also the governing concept behind view composition: You construct compound views by adding subviews to a superview. Finally, the view hierarchy is a critical factor in the multiple coordinate systems found in a window.

image: Art/view_hierarchy_enclose.jpg

Three View Properties Define Relationships in the Hierarchy

A view is related to other views through two properties, and these relationships determine the form of the hierarchy:

image: Art/view_hierarchy_relationships.jpg

Views also include another property that identifies their window.

In iOS, a Window is a View

In Mac OS X a window has a single “content view,” a background view from which, structurally, all other views in the hierarchy descend. However, in iOS applications, a window is a view (UIWindow inherits from UIView), and so it acts as its own content view.

Prerequisite Articles

Sample Code Projects

    (None)

Did this document help you? Yes It's good, but... Not helpful...


Last updated: 2010-07-07